package com.neuedu.javase.thread;

/***
 * 项目名称:  MyJavaSE 
 * 包：  com.neuedu.javase.thread 
 * date:   2025/11/6   10:37  
 * 描述:  
 *  @author : 张金山
 *  作者博客:   https://blog.fulfill.com.cn
 */
public class Runner {


    public static void main(String[] args) throws InterruptedException {

        // Thread

        // MyThread m1 = new MyThread("张三");
        // MyThread m2 = new MyThread("李四");
        //
        //
        // //启动两个线程
        // m1.start();
        // m2.start();


        // Runnable
        Thread myRunnable1 = new Thread(new MyRunnable("李四",5));
        Thread myRunnable2 = new Thread(new MyRunnable("王五",2000));
        System.out.println("myRunnable1.getPriority() = " + myRunnable1.getPriority());   //默认值是5
        System.out.println("myRunnable2.getPriority() = " + myRunnable2.getPriority());
        myRunnable1.setPriority(10);
        myRunnable2.setPriority(1);
        myRunnable1.start();
        myRunnable2.start();





        myRunnable1.join();

        //主线程 也运行
        while(true){
            System.out.println("main方法 主线程在执行...");
            Thread.sleep(1000);

            System.out.printf("myRunnable1.isAlive() =%s， myRunnable2.isAlive：%s " , myRunnable1.isAlive(),myRunnable2.isAlive());
        }


    }
}
